<admintpl file="header"/>
<body class="J_scroll_fixed">
<div class="wrap jj">
  <admintpl file="nav"/>
  <div class="common-form">
    <form method="post" class="J_ajaxForm" action="{:U('nav/edit_post')}">
      <div class="h_a">菜单信息</div>
      <input type="hidden" class="input" name="id" value="{$id}">
      <div class="table_list">
        <table cellpadding="0" cellspacing="0" class="table_form" width="100%">
          <tbody>
            <tr>
              <td>菜单分类:</td>
              <td>
                <select name="cid" id="navcid_select" class="normal_select">
                  <foreach name="navcats" item="vo">
                    <php>$navcid_selected=$navcid==$vo['navcid']?"selected":"";</php>
                  <option value="{$vo.navcid}" {$navcid_selected}>{$vo.name}</option>
                  </foreach>
                </select>
        </td>
            </tr>
            <tr>
              <td>上级:</td>
              <td>
                <select name="parentid" class="normal_select">
                  <option value="0">/</option>
                  {$nav_trees}
                </select>
        </td>
            </tr>
            <tr>
              <td>标签:</td>
              <td><input type="text" class="input" name="label" value="{$label}"><span class="must_red">*</span></td>
            </tr>
<foreach name="navs" item="vo">

  <foreach name="vo['items']" item="voo">
    <?php
      $rules[] = $voo['rule'];
    ?>
  </foreach>
</foreach>
<?php
  $in = in_array($hrefold, $rules);
  // var_dump($in);
?>
            <tr>
              <td>地址:</td>
              <td>
                <input type="radio" name="nav" id="outlink" <if condition="!$in">checked</if>>
                <input type="text" class="input" <if condition="!$in">name="href"</if> id="outlink_input" value="<if condition="!$in">{$hrefold}<else />http://</if>" style="width:200px">
                
                <input type="radio" name="nav" id="selecturl" <if condition="$in">checked</if>>
                <select <if condition="$in">name="href"</if> id="selecthref" class="normal_select">
                  <option disabled="disabled">默认</option>
                  <option value="home">&nbsp;&nbsp;&nbsp;&nbsp;首页</option>
                  <foreach name="navs" item="vo">
                  <option disabled="disabled">{$vo.name}</option>
                    <foreach name="vo['items']" item="voo">
                    <option value='{$voo.rule}' <if condition="$voo['rule'] == $hrefold">selected</if>>&nbsp;&nbsp;&nbsp;&nbsp;{$voo.label}</option>
                    </foreach>
                  </foreach>
                </select>

<!--  -->
                  <br>
                  <br>
            <input type="radio" name="nav" id="wap">移动端 
            <select name="" id="wap_link">
              <option value="/mobile">手机首页</option>
              <volist name="terms" id="vo">
<?php
  $type = ($vo['taxonomy'] == 'product')?'product':'index';
  $href = U("mobile/list/$type",array('id'=>$vo['term_id']),'html');
?>
              <option value="{$href}" style="<if condition="!$vo['html']">background-color: #ccc;color:red<else />color:blue</if>">{$vo.html}{$vo.html}{$vo.name}</option>
              <if condition="!empty($vo['posts']) && $vo['name'] != '单页'">
              <volist name="vo.posts" id="p">
<?php
  $type = ($vo['taxonomy'] == 'product')?'product':'index';
  $href = U("mobile/article/$type",array('id'=>$vo['term_id']),'html');

?>
              <!-- <option value="{$href}">&nbsp;&nbsp;&nbsp;&nbsp;└─{$p.post_title}</option> -->
              </volist>
              <elseif condition="!empty($vo['posts'])"/>
              <volist name="vo.posts" id="p">
              <option value="{:U('mobile/article/page',array('id'=>$p['id']),'html',false,true)}">&nbsp;&nbsp;&nbsp;&nbsp;└─{$p.post_title}</option>
              </volist>
              </if>
              </volist>
            </select>
<!--  -->
                <!-- 
                <textarea readonly="readonly" rows="5" cols="57" id="href_input">{$href}</textarea>
                <input type="hidden" name="href" id="u_input" value='{$hrefold}' />
                 -->
              </td>
            </tr>
            <tr>
              <td>打开方式:</td>
              <td>
                <select name="target">
                  <option value="">默认方式</option>
                  <option value="_blank">新窗口打开</option>
                </select>
        </td>
            </tr>
            <tr>
              <td>图标:</td>
              <td><input type="text" class="input" name="icon" value="{$icon}"></td>
            </tr>
            <tr>
              <td>显示:</td>
              <td>
                <select name="status" class="normal_select">
                  <option value="1">显示</option>
                  <option value="0">隐藏</option>
                </select>
        </td>
            </tr>
               <!--  -->
            <tr>
                <td>Attr_ID:</td>
                <td><input type="text" class="input" name="attr_id" value="{$attr_id}"></td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="btn_wrap">
        <div class="btn_wrap_pd">
          <button class="btn btn_submit mr10 J_ajax_submit_btn" type="submit">更新</button>
          <a class="btn" href="javascript:void(0)" onclick="window.history.go(-1)">返回</a>
        </div>
      </div>
    </form>
  </div>
</div>
<script src="__ROOT__/statics/js/common.js{$js_debug}"></script>
<script>
$(function(){
  $("#navcid_select").change(function(){
    location.href=location.href+"&cid="+$(this).val();
  });
  
  // $("#selecthref").click(function(){
  //   $('#outlink_input').removeAttr('name');
  //   $('#selecturl').attr({'checked':'checked', 'name':'href'});
  // });
  // $("input[name='href']").click(function(){
  //   $('#selecthref').removeAttr('name');
  //   $('#outlink').attr({'checked':'checked', 'name':'href'});
  // });

  $('#outlink').click(function(event) {
    $('#outlink').attr('checked','checked');
    $('#outlink_input').attr('name','href');
    $('#selecthref').removeAttr('name');
    $('#wap_link').removeAttr('name');
  });
  $('#outlink_input').click(function(event) {
    $('#outlink').attr('checked','checked');
    $(this).attr('name','href');
    $('#selecthref').removeAttr('name');
    $('#wap_link').removeAttr('name');
  });
// 
  $('#selecturl').click(function(event) {
    $('#selecthref').attr('name','href');
    $('#selecturl').attr('checked','checked');
    $('#outlink_input').removeAttr('name');
    $('#wap_link').removeAttr('name');
  });

  $('#selecthref').click(function(event) {
    $(this).attr('name','href');
    $('#selecturl').attr('checked','checked');
    $('#outlink_input').removeAttr('name');
    $('#wap_link').removeAttr('name');
  });
// 
  $('#wap').click(function(event) {
    $('#wap_link').attr('name','href');
    $('#wap').attr('checked','checked');
    $('#outlink_input').removeAttr('name');
    $('#selecthref').removeAttr('name');
  });

  $('#wap_link').click(function(event) {
    $(this).attr('name','href');
    $('#wap').attr('checked','checked');
    $('#outlink_input').removeAttr('name');
    $('#selecthref').removeAttr('name');
  });
  // $("#navcid_select").change(function(){
  //  location.href=location.href+"&cid="+$(this).val();
  // });
  
  // $("#selecthref").click(function(){
  //  checkChange(2);
  // });
  // $("input[name='href']").click(function(){
  //  checkChange(1);
  // });
  
  // var opt = $("#selecthref option[value='"+'{$hrefold}'+"']");
  // if(opt.length > 0){
  //  opt.attr('selected','selected');
  //  checkChange(2);
  // }else{
  //  checkChange(1);
  //  $('#outlink_input').val('{$hrefold}');
  // }
  
  // function checkChange(i){
  //  if(i==1){
  //    //自动输入url
  //    $('#outlink_input').attr('name','href');
  //    $('#selecthref').removeAttr('name');
  //    $('#outlink').attr({'checked':'checked', 'name':'nav'});
  //  }else{
  //    //选择链接url
  //    $('#selecthref').attr('name','href');
  //    $('#outlink_input').removeAttr('name');
  //    $('#selecturl').attr({'checked':'checked', 'name':'nav'});
  //  }
  // }
  /*
  Wind.use('ajaxForm','artDialog','iframeTools', function () {
    $("#href_input").click(function(){
      art.dialog.data('menu_url', $("#href_input").val());
      art.dialog.open("{:u('nav/select')}", {
                title: "选择链接地址",
                close: function () {
              var checked_v = art.dialog.data('checked_v');
              var checked_u = art.dialog.data('checked_u');
              if (checked_v !== undefined) $('#href_input').val(checked_v);
              if (checked_u !== undefined) $('#u_input').val(checked_u);
            }
            },false);
    });
    });
  */
});


</script>
</body>
</html>